<?php

class Snapshot_Controller extends Template_Controller {
    public function __construct(){
        $this->need_template = false;
        if (in_array(Router::$method, array ('index')) ) {
            $this->need_template = true;
        }

        parent::__construct();
    }

    public function index($competition_id = null){
        $this->title = "Snapshot";

        $competition = null;

        if ($competition_id == null) {
            $competition = ORM::factory('competition')->get_last_competition();
        } else {
            $competition = ORM::factory('competition', $competition_id);
        }
    }

    public function get_all_photos($competition_id = null) {
        $competition = null;
        if ($competition_id == null) {
            $competition = ORM::factory('competition')->get_last_competition();
        } else {
            $competition = ORM::factory('competition', $competition_id);
        }

        $retval = array();

        $i = 0;
        foreach ($competition->photos as $photo) {
            $retval[$i] = $photo->path;
            ++$i;
        }

        echo json_encode($retval);
    }
}
?>
